
#pragma once

#include "../parser.h"

namespace serial {

class FsmQuickset : public Parser::FSM {
public:
    // > 0 : success
    // = 0 : need more
    // < 0 : failed.
    virtual int onData(unsigned char data);
    virtual void reset();
private:
    typedef enum {
        S_INIT,
        S_DD,
        S_FF,
        S_LEN1,
        S_LEN2,
        S_CMD1,
        S_CMD2,
        S_CMD3,
        S_CMD4,
        S_DATA,
        S_CHK,
        S_BB,
        S_CC,
    } State;
    State mState;
    int changeState(State s);
    int fail(const char * reason);
    int len;
    unsigned char chk;
};
} // namespace serial

